package kr.hkit.powerjava.chapter24;

import java.io.*;

public class CopyFileStream {
	public static void main(String[] args) {
	/* FileInputStream fis = null;
		FileOutputStream fos = null;*/
		
		BufferedInputStream fis = null;
		BufferedOutputStream fos = null;
		
		long start, end;	
		try {
			 fis = new BufferedInputStream(new FileInputStream("Chrysanthemum.jpg"));
			 fos = new BufferedOutputStream(new FileOutputStream("수국.jpg",true));		//append 추가...
			 start = System.currentTimeMillis();
			 
			 int c;
			 while((c = fis.read()) != -1){
/*				 System.out.printf("%s", (char)c);
*/				 fos.write(c);
			 }
			 end = System.currentTimeMillis();
			 
			 System.out.println("걸린 시간 	" + (end-start));
		} catch (FileNotFoundException e) {
			System.err.format("%s%n", "파일이 존재 하지 않음");
		} catch (IOException e) {
			e.printStackTrace();
		}  finally{
			if(fis != null){
				try{fis.close();}catch(Exception e){}
			if(fos != null){
				try{fos.close();}catch(Exception e){}
			}
			}
		}
	}
}
